// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Ingest;

public sealed partial class SetProcessor
{
	/// <summary>
	/// <para>
	/// The origin field which will be copied to <c>field</c>, cannot set <c>value</c> simultaneously.
	/// Supported data types are <c>boolean</c>, <c>number</c>, <c>array</c>, <c>object</c>, <c>string</c>, <c>date</c>, etc.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("copy_from")]
	public Elastic.Clients.Elasticsearch.Field? CopyFrom { get; set; }

	/// <summary>
	/// <para>
	/// Description of the processor.
	/// Useful for describing the purpose of the processor or its configuration.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("description")]
	public string? Description { get; set; }

	/// <summary>
	/// <para>
	/// The field to insert, upsert, or update.
	/// Supports template snippets.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("field")]
	public Elastic.Clients.Elasticsearch.Field Field { get; set; }

	/// <summary>
	/// <para>
	/// Conditionally execute the processor.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("if")]
	public string? If { get; set; }

	/// <summary>
	/// <para>
	/// If <c>true</c> and <c>value</c> is a template snippet that evaluates to <c>null</c> or the empty string, the processor quietly exits without modifying the document.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("ignore_empty_value")]
	public bool? IgnoreEmptyValue { get; set; }

	/// <summary>
	/// <para>
	/// Ignore failures for the processor.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("ignore_failure")]
	public bool? IgnoreFailure { get; set; }

	/// <summary>
	/// <para>
	/// The media type for encoding <c>value</c>.
	/// Applies only when value is a template snippet.
	/// Must be one of <c>application/json</c>, <c>text/plain</c>, or <c>application/x-www-form-urlencoded</c>.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("media_type")]
	public string? MediaType { get; set; }

	/// <summary>
	/// <para>
	/// Handle failures for the processor.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("on_failure")]
	public ICollection<Elastic.Clients.Elasticsearch.Ingest.Processor>? OnFailure { get; set; }

	/// <summary>
	/// <para>
	/// If <c>true</c> processor will update fields with pre-existing non-null-valued field.
	/// When set to <c>false</c>, such fields will not be touched.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("override")]
	public bool? Override { get; set; }

	/// <summary>
	/// <para>
	/// Identifier for the processor.
	/// Useful for debugging and metrics.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("tag")]
	public string? Tag { get; set; }

	/// <summary>
	/// <para>
	/// The value to be set for the field.
	/// Supports template snippets.
	/// May specify only one of <c>value</c> or <c>copy_from</c>.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("value")]
	public object? Value { get; set; }

	public static implicit operator Elastic.Clients.Elasticsearch.Ingest.Processor(SetProcessor setProcessor) => Elastic.Clients.Elasticsearch.Ingest.Processor.Set(setProcessor);
}

public sealed partial class SetProcessorDescriptor<TDocument> : SerializableDescriptor<SetProcessorDescriptor<TDocument>>
{
	internal SetProcessorDescriptor(Action<SetProcessorDescriptor<TDocument>> configure) => configure.Invoke(this);

	public SetProcessorDescriptor() : base()
	{
	}

	private Elastic.Clients.Elasticsearch.Field? CopyFromValue { get; set; }
	private string? DescriptionValue { get; set; }
	private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; }
	private string? IfValue { get; set; }
	private bool? IgnoreEmptyValueValue { get; set; }
	private bool? IgnoreFailureValue { get; set; }
	private string? MediaTypeValue { get; set; }
	private ICollection<Elastic.Clients.Elasticsearch.Ingest.Processor>? OnFailureValue { get; set; }
	private Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor<TDocument> OnFailureDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor<TDocument>> OnFailureDescriptorAction { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor<TDocument>>[] OnFailureDescriptorActions { get; set; }
	private bool? OverrideValue { get; set; }
	private string? TagValue { get; set; }
	private object? ValueValue { get; set; }

	/// <summary>
	/// <para>
	/// The origin field which will be copied to <c>field</c>, cannot set <c>value</c> simultaneously.
	/// Supported data types are <c>boolean</c>, <c>number</c>, <c>array</c>, <c>object</c>, <c>string</c>, <c>date</c>, etc.
	/// </para>
	/// </summary>
	public SetProcessorDescriptor<TDocument> CopyFrom(Elastic.Clients.Elasticsearch.Field? copyFrom)
	{
		CopyFromValue = copyFrom;
		return Self;
	}

	/// <summary>
	/// <para>
	/// The origin field which will be copied to <c>field</c>, cannot set <c>value</c> simultaneously.
	/// Supported data types are <c>boolean</c>, <c>number</c>, <c>array</c>, <c>object</c>, <c>string</c>, <c>date</c>, etc.
	/// </para>
	/// </summary>
	public SetProcessorDescriptor<TDocument> CopyFrom<TValue>(Expression<Func<TDocument, TValue>> copyFrom)
	{
		CopyFromValue = copyFrom;
		return Self;
	}

	/// <summary>
	/// <para>
	/// The origin field which will be copied to <c>field</c>, cannot set <c>value</c> simultaneously.
	/// Supported data types are <c>boolean</c>, <c>number</c>, <c>array</c>, <c>object</c>, <c>string</c>, <c>date</c>, etc.
	/// </para>
	/// </summary>
	public SetProcessorDescriptor<TDocument> CopyFrom(Expression<Func<TDocument, object>> copyFrom)
	{
		CopyFromValue = copyFrom;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Description of the processor.
	/// Useful for describing the purpose of the processor or its configuration.
	/// </para>
	/// </summary>
	public SetProcessorDescriptor<TDocument> Description(string? description)
	{
		DescriptionValue = description;
		return Self;
	}

	/// <summary>
	/// <para>
	/// The field to insert, upsert, or update.
	/// Supports template snippets.
	/// </para>
	/// </summary>
	public SetProcessorDescriptor<TDocument> Field(Elastic.Clients.Elasticsearch.Field field)
	{
		FieldValue = field;
		return Self;
	}

	/// <summary>
	/// <para>
	/// The field to insert, upsert, or update.
	/// Supports template snippets.
	/// </para>
	/// </summary>
	public SetProcessorDescriptor<TDocument> Field<TValue>(Expression<Func<TDocument, TValue>> field)
	{
		FieldValue = field;
		return Self;
	}

	/// <summary>
	/// <para>
	/// The field to insert, upsert, or update.
	/// Supports template snippets.
	/// </para>
	/// </summary>
	public SetProcessorDescriptor<TDocument> Field(Expression<Func<TDocument, object>> field)
	{
		FieldValue = field;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Conditionally execute the processor.
	/// </para>
	/// </summary>
	public SetProcessorDescriptor<TDocument> If(string? value)
	{
		IfValue = value;
		return Self;
	}

	/// <summary>
	/// <para>
	/// If <c>true</c> and <c>value</c> is a template snippet that evaluates to <c>null</c> or the empty string, the processor quietly exits without modifying the document.
	/// </para>
	/// </summary>
	public SetProcessorDescriptor<TDocument> IgnoreEmptyValue(bool? ignoreEmptyValue = true)
	{
		IgnoreEmptyValueValue = ignoreEmptyValue;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Ignore failures for the processor.
	/// </para>
	/// </summary>
	public SetProcessorDescriptor<TDocument> IgnoreFailure(bool? ignoreFailure = true)
	{
		IgnoreFailureValue = ignoreFailure;
		return Self;
	}

	/// <summary>
	/// <para>
	/// The media type for encoding <c>value</c>.
	/// Applies only when value is a template snippet.
	/// Must be one of <c>application/json</c>, <c>text/plain</c>, or <c>application/x-www-form-urlencoded</c>.
	/// </para>
	/// </summary>
	public SetProcessorDescriptor<TDocument> MediaType(string? mediaType)
	{
		MediaTypeValue = mediaType;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Handle failures for the processor.
	/// </para>
	/// </summary>
	public SetProcessorDescriptor<TDocument> OnFailure(ICollection<Elastic.Clients.Elasticsearch.Ingest.Processor>? onFailure)
	{
		OnFailureDescriptor = null;
		OnFailureDescriptorAction = null;
		OnFailureDescriptorActions = null;
		OnFailureValue = onFailure;
		return Self;
	}

	public SetProcessorDescriptor<TDocument> OnFailure(Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor<TDocument> descriptor)
	{
		OnFailureValue = null;
		OnFailureDescriptorAction = null;
		OnFailureDescriptorActions = null;
		OnFailureDescriptor = descriptor;
		return Self;
	}

	public SetProcessorDescriptor<TDocument> OnFailure(Action<Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor<TDocument>> configure)
	{
		OnFailureValue = null;
		OnFailureDescriptor = null;
		OnFailureDescriptorActions = null;
		OnFailureDescriptorAction = configure;
		return Self;
	}

	public SetProcessorDescriptor<TDocument> OnFailure(params Action<Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor<TDocument>>[] configure)
	{
		OnFailureValue = null;
		OnFailureDescriptor = null;
		OnFailureDescriptorAction = null;
		OnFailureDescriptorActions = configure;
		return Self;
	}

	/// <summary>
	/// <para>
	/// If <c>true</c> processor will update fields with pre-existing non-null-valued field.
	/// When set to <c>false</c>, such fields will not be touched.
	/// </para>
	/// </summary>
	public SetProcessorDescriptor<TDocument> Override(bool? value = true)
	{
		OverrideValue = value;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Identifier for the processor.
	/// Useful for debugging and metrics.
	/// </para>
	/// </summary>
	public SetProcessorDescriptor<TDocument> Tag(string? tag)
	{
		TagValue = tag;
		return Self;
	}

	/// <summary>
	/// <para>
	/// The value to be set for the field.
	/// Supports template snippets.
	/// May specify only one of <c>value</c> or <c>copy_from</c>.
	/// </para>
	/// </summary>
	public SetProcessorDescriptor<TDocument> Value(object? value)
	{
		ValueValue = value;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (CopyFromValue is not null)
		{
			writer.WritePropertyName("copy_from");
			JsonSerializer.Serialize(writer, CopyFromValue, options);
		}

		if (!string.IsNullOrEmpty(DescriptionValue))
		{
			writer.WritePropertyName("description");
			writer.WriteStringValue(DescriptionValue);
		}

		writer.WritePropertyName("field");
		JsonSerializer.Serialize(writer, FieldValue, options);
		if (!string.IsNullOrEmpty(IfValue))
		{
			writer.WritePropertyName("if");
			writer.WriteStringValue(IfValue);
		}

		if (IgnoreEmptyValueValue.HasValue)
		{
			writer.WritePropertyName("ignore_empty_value");
			writer.WriteBooleanValue(IgnoreEmptyValueValue.Value);
		}

		if (IgnoreFailureValue.HasValue)
		{
			writer.WritePropertyName("ignore_failure");
			writer.WriteBooleanValue(IgnoreFailureValue.Value);
		}

		if (!string.IsNullOrEmpty(MediaTypeValue))
		{
			writer.WritePropertyName("media_type");
			writer.WriteStringValue(MediaTypeValue);
		}

		if (OnFailureDescriptor is not null)
		{
			writer.WritePropertyName("on_failure");
			writer.WriteStartArray();
			JsonSerializer.Serialize(writer, OnFailureDescriptor, options);
			writer.WriteEndArray();
		}
		else if (OnFailureDescriptorAction is not null)
		{
			writer.WritePropertyName("on_failure");
			writer.WriteStartArray();
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor<TDocument>(OnFailureDescriptorAction), options);
			writer.WriteEndArray();
		}
		else if (OnFailureDescriptorActions is not null)
		{
			writer.WritePropertyName("on_failure");
			writer.WriteStartArray();
			foreach (var action in OnFailureDescriptorActions)
			{
				JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor<TDocument>(action), options);
			}

			writer.WriteEndArray();
		}
		else if (OnFailureValue is not null)
		{
			writer.WritePropertyName("on_failure");
			JsonSerializer.Serialize(writer, OnFailureValue, options);
		}

		if (OverrideValue.HasValue)
		{
			writer.WritePropertyName("override");
			writer.WriteBooleanValue(OverrideValue.Value);
		}

		if (!string.IsNullOrEmpty(TagValue))
		{
			writer.WritePropertyName("tag");
			writer.WriteStringValue(TagValue);
		}

		if (ValueValue is not null)
		{
			writer.WritePropertyName("value");
			JsonSerializer.Serialize(writer, ValueValue, options);
		}

		writer.WriteEndObject();
	}
}

public sealed partial class SetProcessorDescriptor : SerializableDescriptor<SetProcessorDescriptor>
{
	internal SetProcessorDescriptor(Action<SetProcessorDescriptor> configure) => configure.Invoke(this);

	public SetProcessorDescriptor() : base()
	{
	}

	private Elastic.Clients.Elasticsearch.Field? CopyFromValue { get; set; }
	private string? DescriptionValue { get; set; }
	private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; }
	private string? IfValue { get; set; }
	private bool? IgnoreEmptyValueValue { get; set; }
	private bool? IgnoreFailureValue { get; set; }
	private string? MediaTypeValue { get; set; }
	private ICollection<Elastic.Clients.Elasticsearch.Ingest.Processor>? OnFailureValue { get; set; }
	private Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor OnFailureDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor> OnFailureDescriptorAction { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor>[] OnFailureDescriptorActions { get; set; }
	private bool? OverrideValue { get; set; }
	private string? TagValue { get; set; }
	private object? ValueValue { get; set; }

	/// <summary>
	/// <para>
	/// The origin field which will be copied to <c>field</c>, cannot set <c>value</c> simultaneously.
	/// Supported data types are <c>boolean</c>, <c>number</c>, <c>array</c>, <c>object</c>, <c>string</c>, <c>date</c>, etc.
	/// </para>
	/// </summary>
	public SetProcessorDescriptor CopyFrom(Elastic.Clients.Elasticsearch.Field? copyFrom)
	{
		CopyFromValue = copyFrom;
		return Self;
	}

	/// <summary>
	/// <para>
	/// The origin field which will be copied to <c>field</c>, cannot set <c>value</c> simultaneously.
	/// Supported data types are <c>boolean</c>, <c>number</c>, <c>array</c>, <c>object</c>, <c>string</c>, <c>date</c>, etc.
	/// </para>
	/// </summary>
	public SetProcessorDescriptor CopyFrom<TDocument, TValue>(Expression<Func<TDocument, TValue>> copyFrom)
	{
		CopyFromValue = copyFrom;
		return Self;
	}

	/// <summary>
	/// <para>
	/// The origin field which will be copied to <c>field</c>, cannot set <c>value</c> simultaneously.
	/// Supported data types are <c>boolean</c>, <c>number</c>, <c>array</c>, <c>object</c>, <c>string</c>, <c>date</c>, etc.
	/// </para>
	/// </summary>
	public SetProcessorDescriptor CopyFrom<TDocument>(Expression<Func<TDocument, object>> copyFrom)
	{
		CopyFromValue = copyFrom;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Description of the processor.
	/// Useful for describing the purpose of the processor or its configuration.
	/// </para>
	/// </summary>
	public SetProcessorDescriptor Description(string? description)
	{
		DescriptionValue = description;
		return Self;
	}

	/// <summary>
	/// <para>
	/// The field to insert, upsert, or update.
	/// Supports template snippets.
	/// </para>
	/// </summary>
	public SetProcessorDescriptor Field(Elastic.Clients.Elasticsearch.Field field)
	{
		FieldValue = field;
		return Self;
	}

	/// <summary>
	/// <para>
	/// The field to insert, upsert, or update.
	/// Supports template snippets.
	/// </para>
	/// </summary>
	public SetProcessorDescriptor Field<TDocument, TValue>(Expression<Func<TDocument, TValue>> field)
	{
		FieldValue = field;
		return Self;
	}

	/// <summary>
	/// <para>
	/// The field to insert, upsert, or update.
	/// Supports template snippets.
	/// </para>
	/// </summary>
	public SetProcessorDescriptor Field<TDocument>(Expression<Func<TDocument, object>> field)
	{
		FieldValue = field;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Conditionally execute the processor.
	/// </para>
	/// </summary>
	public SetProcessorDescriptor If(string? value)
	{
		IfValue = value;
		return Self;
	}

	/// <summary>
	/// <para>
	/// If <c>true</c> and <c>value</c> is a template snippet that evaluates to <c>null</c> or the empty string, the processor quietly exits without modifying the document.
	/// </para>
	/// </summary>
	public SetProcessorDescriptor IgnoreEmptyValue(bool? ignoreEmptyValue = true)
	{
		IgnoreEmptyValueValue = ignoreEmptyValue;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Ignore failures for the processor.
	/// </para>
	/// </summary>
	public SetProcessorDescriptor IgnoreFailure(bool? ignoreFailure = true)
	{
		IgnoreFailureValue = ignoreFailure;
		return Self;
	}

	/// <summary>
	/// <para>
	/// The media type for encoding <c>value</c>.
	/// Applies only when value is a template snippet.
	/// Must be one of <c>application/json</c>, <c>text/plain</c>, or <c>application/x-www-form-urlencoded</c>.
	/// </para>
	/// </summary>
	public SetProcessorDescriptor MediaType(string? mediaType)
	{
		MediaTypeValue = mediaType;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Handle failures for the processor.
	/// </para>
	/// </summary>
	public SetProcessorDescriptor OnFailure(ICollection<Elastic.Clients.Elasticsearch.Ingest.Processor>? onFailure)
	{
		OnFailureDescriptor = null;
		OnFailureDescriptorAction = null;
		OnFailureDescriptorActions = null;
		OnFailureValue = onFailure;
		return Self;
	}

	public SetProcessorDescriptor OnFailure(Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor descriptor)
	{
		OnFailureValue = null;
		OnFailureDescriptorAction = null;
		OnFailureDescriptorActions = null;
		OnFailureDescriptor = descriptor;
		return Self;
	}

	public SetProcessorDescriptor OnFailure(Action<Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor> configure)
	{
		OnFailureValue = null;
		OnFailureDescriptor = null;
		OnFailureDescriptorActions = null;
		OnFailureDescriptorAction = configure;
		return Self;
	}

	public SetProcessorDescriptor OnFailure(params Action<Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor>[] configure)
	{
		OnFailureValue = null;
		OnFailureDescriptor = null;
		OnFailureDescriptorAction = null;
		OnFailureDescriptorActions = configure;
		return Self;
	}

	/// <summary>
	/// <para>
	/// If <c>true</c> processor will update fields with pre-existing non-null-valued field.
	/// When set to <c>false</c>, such fields will not be touched.
	/// </para>
	/// </summary>
	public SetProcessorDescriptor Override(bool? value = true)
	{
		OverrideValue = value;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Identifier for the processor.
	/// Useful for debugging and metrics.
	/// </para>
	/// </summary>
	public SetProcessorDescriptor Tag(string? tag)
	{
		TagValue = tag;
		return Self;
	}

	/// <summary>
	/// <para>
	/// The value to be set for the field.
	/// Supports template snippets.
	/// May specify only one of <c>value</c> or <c>copy_from</c>.
	/// </para>
	/// </summary>
	public SetProcessorDescriptor Value(object? value)
	{
		ValueValue = value;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (CopyFromValue is not null)
		{
			writer.WritePropertyName("copy_from");
			JsonSerializer.Serialize(writer, CopyFromValue, options);
		}

		if (!string.IsNullOrEmpty(DescriptionValue))
		{
			writer.WritePropertyName("description");
			writer.WriteStringValue(DescriptionValue);
		}

		writer.WritePropertyName("field");
		JsonSerializer.Serialize(writer, FieldValue, options);
		if (!string.IsNullOrEmpty(IfValue))
		{
			writer.WritePropertyName("if");
			writer.WriteStringValue(IfValue);
		}

		if (IgnoreEmptyValueValue.HasValue)
		{
			writer.WritePropertyName("ignore_empty_value");
			writer.WriteBooleanValue(IgnoreEmptyValueValue.Value);
		}

		if (IgnoreFailureValue.HasValue)
		{
			writer.WritePropertyName("ignore_failure");
			writer.WriteBooleanValue(IgnoreFailureValue.Value);
		}

		if (!string.IsNullOrEmpty(MediaTypeValue))
		{
			writer.WritePropertyName("media_type");
			writer.WriteStringValue(MediaTypeValue);
		}

		if (OnFailureDescriptor is not null)
		{
			writer.WritePropertyName("on_failure");
			writer.WriteStartArray();
			JsonSerializer.Serialize(writer, OnFailureDescriptor, options);
			writer.WriteEndArray();
		}
		else if (OnFailureDescriptorAction is not null)
		{
			writer.WritePropertyName("on_failure");
			writer.WriteStartArray();
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor(OnFailureDescriptorAction), options);
			writer.WriteEndArray();
		}
		else if (OnFailureDescriptorActions is not null)
		{
			writer.WritePropertyName("on_failure");
			writer.WriteStartArray();
			foreach (var action in OnFailureDescriptorActions)
			{
				JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor(action), options);
			}

			writer.WriteEndArray();
		}
		else if (OnFailureValue is not null)
		{
			writer.WritePropertyName("on_failure");
			JsonSerializer.Serialize(writer, OnFailureValue, options);
		}

		if (OverrideValue.HasValue)
		{
			writer.WritePropertyName("override");
			writer.WriteBooleanValue(OverrideValue.Value);
		}

		if (!string.IsNullOrEmpty(TagValue))
		{
			writer.WritePropertyName("tag");
			writer.WriteStringValue(TagValue);
		}

		if (ValueValue is not null)
		{
			writer.WritePropertyName("value");
			JsonSerializer.Serialize(writer, ValueValue, options);
		}

		writer.WriteEndObject();
	}
}